﻿#ifndef TIMETASKS_H
#define TIMETASKS_H

#include <QObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QJsonValue>


#include <QMap>
#include <QPair>
#include <QTimer>

#include <QThread>

class TasksThread : public QThread
{

    Q_OBJECT
public:
    explicit TasksThread(QObject *parent = nullptr);
    virtual ~TasksThread();

    void stopRun();

    void startRun();

    void setPinTime(int pins , QPair<int ,int> pairs );

    int getPins();

signals:
    void sigTimeTasks(int pin , int statues);


public slots:


protected:
    void run();


private:
    bool m_isStop;

    int m_pins;

    QPair<int ,int> m_runTimes;
};

/*
 * 定时处理任务
*/
class TimeTasks : public QObject
{
    Q_OBJECT
public:
    explicit TimeTasks(QObject *parent = nullptr);
    virtual ~TimeTasks();

    static TimeTasks * gestance();

    void initTimeTasks();
    void updateTimeTasks();

    void runAll();
    void runIndexs(int inmdexs);
    void stopIndexs(int inmdexs);

signals:
    void sigTimeTasks(int pin , int statues);



public slots:


private:
    static TimeTasks  * m_timeTasks;
    QList<TasksThread * > m_allTasksThread;
};

#endif // TIMETASKS_H
